﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleModelManager.aspx.cs" Inherits="RegisterWeb.Manager.SystemUserManager.RoleModelManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
       <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body>
    <form id="rolemodel" runat="server">
    <table id="tt">
	</table>
    	<script type="text/javascript">
    	    var url;
    	    var row1;
    	    function DeleteRoleModel() {
    	        var row = $('#tt').datagrid('getSelected');
    	        if (confirm("确定要删除该权限吗？")) {
    	            $.post("ashx/RoleModelService.ashx", { "action": "delete", "Role_ID": row1.Role_ID, "ModuleInfo_ID": row.ModuleInfo_ID }, function (data, status) {
    	                if (status == "success") {
    	                    if (data == "ok") {
    	                        alert("该权限删除成功！");
    	                        $('#tt').datagrid("reload")
    	                    }
    	                    else
    	                        alert("删除失败！");
    	                }
    	                else
    	                    alert("网络连接错误，删除失败！");
    	            });
    	        }
    	    }
    	    function addeRoleModel() {
    	        //alert("11");
    	        var row = $('#tt').datagrid('getSelected');
    	        if (confirm("确定要添加该权限吗？")) {
    	            $.post("ashx/RoleModelService.ashx", { "action": "add", "Role_ID": row1.Role_ID, "ModuleInfo_ID": row.ModuleInfo_ID }, function (data, status) {
    	                if (status == "success") {
    	                    if (data == "ok") {
    	                        alert("该权限添加成功！");
    	                        $('#tt').datagrid("reload")
    	                    }
    	                    else
    	                        alert("添加失败！");
    	                }
    	                else
    	                    alert("网络连接错误，删除失败！");
    	            });
    	        }

    	    }

    	    $(function () {
    	   
    	        $('#tt').datagrid({
    	            title: '',
    	            iconCls: 'icon-edit',
    	            width: 860,
    	            height: 250,
    	            singleSelect: true,
    	            pagination: true,
    	            rownumbers: true,
    	            fitColumns: true,
    	            idField: 'itemid',
    	            url: 'ashx/RoleModelService.ashx?action=get&Roleid=' + row1.Role_ID,
    	            columns: [[
						{ field: 'ModuleTopInfo_Name', title: '一级模块名', width: 80 },
     	         	{ field: 'ModuleInfo_Page', title: '模块路径', width: 130 },
                 	{ field: 'ModuleInfo_Name', title: '二级模块名', width: 120 },
                  	{ field: 'ModuleInfo_Describe', title: '模块描述', width: 120 },
			    	{ field: 'ModuleInfo_int ', title: '操作', width: 80, align: 'center',
			    	    formatter: function (value, row, index) {
//			    	        alert(row.ModuleInfo_int);
			    	        if (row.ModuleInfo_int == "0") {
			    	            var c = '<a href="#" onclick="addeRoleModel()">指定权限</a>';
			    	            return c;
			    	        } else {
			    	            var d = '<a href="#" onclick="DeleteRoleModel() ">删除权限</a>';
			    	            return d;
			    	        }
			    	    }
			    	}
                    ]]
    	        });
    	    });
	</script> 
    </form>
</body>
</html>

